#include <bits/stdc++.h>
using namespace std;
const int N = 1001;
int x[N], y[N], w[N];
int dp[601][601];
//  设dp[i][g][s]是可选物品为1,2....i,得到金为g，得到银为s时的二维0-1背包问题的最优值
int main() {
  int n, a, b;
  cin >> n >> a >> b;
  for (int i = 1; i <= n; i++) {
    cin >> x[i] >> y[i] >> w[i];
  }
  memset(dp, 0x3f, sizeof(dp)); 
  dp[0][0] = 0;
  for (int i = 1; i <= n; i++) {
    for (int g = a; g >= 0; g--) {
      for (int s = b; s >= 0; s--) {
        int ng = min(a, g + x[i]);
        int ns = min(b, s + y[i]);
        dp[ng][ns] = min(dp[ng][ns], dp[g][s] + w[i]);
      }
    }
  }
  cout << dp[a][b];

  return 0;
}